package org.chen.spring.cloud.finchley.service;

import org.chen.spring.cloud.finchley.config.FeignMultipartSupportConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author chensj
 * @date 2020-02-07 21:35
 */
@FeignClient(value = "feign-file-server", configuration = FeignMultipartSupportConfig.class)
public interface FeignUploadService {

    /**
     * 1、produces、consumes必填
     * 2、注意区分 @RequestPart和@RequestParam，不要讲 @RequestPart写成@RequestParam
     *
     * @param file 上传文件
     * @return 结果
     */
    @RequestMapping(method = RequestMethod.POST, value = "/upload/server",
            produces = {MediaType.APPLICATION_JSON_UTF8_VALUE},
            consumes = MediaType.MULTIPART_FORM_DATA_VALUE
    )
    public String uploadFile(@RequestPart(value = "file") MultipartFile file);
}
